﻿using System;
using System.Collections.Generic;
using JetBrains.Annotations;

namespace com.susi.util.toolkit {
    /// <summary>
    ///     包装一个比较器
    /// </summary>
    public class IComparerAdapter<T> : IComparer<T> {
        private Func<T, T, int> CompareFunc;


        public IComparerAdapter([NotNull] Func<T, T, int> compareFunc)
        {
            CompareFunc = compareFunc ?? throw new ArgumentNullException(nameof(compareFunc));
        }

        public int Compare(T x, T y)
        {
            return CompareFunc(x, y);
        }
    }
}